#include "bsp_usb.h"


int8_t usb_ret;
int usb_conn_cnt=0;

void usb_init(void)
{
	#undef CUSTOM_HID_EPIN_SIZE
	//#ifndef CUSTOM_HID_EPIN_SIZE
	#define CUSTOM_HID_EPIN_SIZE                         0x40U
	//#endif /* CUSTOM_HID_EPIN_SIZE */

	#undef CUSTOM_HID_EPOUT_SIZE
	//#ifndef CUSTOM_HID_EPOUT_SIZE
	#define CUSTOM_HID_EPOUT_SIZE                        0x40U
	//#endif /* CUSTOM_HID_EPOUT_SIZE*/
	MX_USB_DEVICE_Init();
}

void usb_data_send(uint8_t *data)
{
    usb_ret=USBD_CUSTOM_HID_SendReport_FS(data,64);
		usb_nuc_offline_dect(usb_ret);
}


void usb_nuc_offline_dect(int8_t ret)
{
	if(ret==0x01){
			usb_conn_cnt+=5;
		}
	else if(ret==0x00){
		usb_conn_cnt=0;
	}
		if(usb_conn_cnt>10000){
			usb_init();
			usb_conn_cnt=0;
		}
}

